#include <iostream>
#include <string>
#include "world.h"
#include "mobile.h"
#include "robot.h"

using namespace std;

bool World::isObjectAtLocation(int y,int x){
	if(y >= 0 && y < map->getMaxY()){
		if(x >= 0 && x < map->getMaxX()){
			return xygrid[y][x];
		}
		else{
			return true;
		}
	}
	else{
		return true;
	}
}


void World::updateRobotLocation(string type,Location *loc){
	int y = loc->getYlocation();
	int x = loc->getPrevXlocation();
	int old_y = loc->getPrevYlocation();
	int old_x = loc->getPrevXlocation();

	xygrid[old_y][old_x] = false;
	xygrid[y][x] = true;

	type_grid[old_y][old_x] = "none";
	type_grid[y][x] = type;

}

void World::initialize(){
	xygrid = map->outputGrid();
	string none = "none";
	for(int i=0; i<map->getMaxY(); ++i){
		vector<string> row;
		for(int j=0; j<map->getMaxX(); ++j){
			row.push_back(none);
		}
		type_grid.push_back(row);
	}
}
